<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>重要公告</title>
    <!-- title前面小图标 -->
    <link rel="shortcut icon" type="image/x-icon" href="public/images/huobi.png" />
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <!-- 样式表-->
    <link href="public/css/index.css" rel="stylesheet">
  <link href="public/css/request.css" rel="stylesheet">
    <script src="public/js/hc_enduser.js"></script>
    <script src="public/js/script.js"></script>
    <script src="public/js/snippet.js"></script>
    <script src="public/js/Token.js"></script>
    <!-- Vue的配置 -->
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.8/vue.min.js"></script>
</head>

<body>
    <!-- 头部内容 -->
    <div class="row clearfix">
        <div class="col-md-12 column">
            <header class="header">
                <!-- logo -->
                <div class="logo">
                    <img src="public/images/logo.png" />
                </div>
                <div class="nav-wrapper">
                    <span class="icon-menu"></span>
                    <nav class="user-nav" id="user-nav">
                        <a class="submit-a-request" href="SubmitRequests.html">提交请求</a>
                    </nav>
                </div>
            </header>
        </div>
    </div>
    <!-- 中间内容部分 -->
    <main role="main">
        <div class="container-divider"></div>
        <div class="container">
            <nav class="sub-nav">
                <ol class="breadcrumbs">
                    <li title="帮助中心">
                        <a href="index.html">帮助中心</a>
                    </li>
                    <li title="Huobi Global 公告">
                        <a href="HuobiNotice.html">Huobi Global 公告</a>
                    </li>
                    <li title="重要公告">
                        <a href="">重要公告</a>
                    </li>
                </ol>
                <div role="search" class="search " data-search="" data-instant="true" autocomplete="off">
                    <input name="" type="hidden" value="">
                    <input type="search" name="" id="query" autocomplete="off" placeholder="搜索" aria-label="搜索">
                </div>
            </nav>
            <div class="section-container">
                <section class="section-content">
                    <header class="page-header">
                        <h1 id="cname">
                            重要公告
                        </h1>
                        <div class="section-subscribe dropdown" aria-haspopup="true">
                            <a class="dropdown-toggle" id="attend" role="button" data-auth-action="signin"
                                aria-selected="false" title="打开登录对话框" href="javascript:;">关注</a>
                            <span class="dropdown-menu" role="menu" aria-expanded="false">
                                <a rel="nofollow" role="menuitem" data-method="" href="">新文章</a>
                                <a rel="nofollow" role="menuitem" data-method="" href="">新文章和评论</a>
                            </span>
                        </div>
                    </header>
                    <div id="category">
                        <ul class="article-list">
                            <li class="article-list-item  article-promoted" v-for="site in datas">
                                <div v-if="site.recommend==='on'" style="display: inline-block">
                                    <span data-title="被推荐的文章" class="icon-star"></span></div>
                                <a href="" class="article-list-link">{{site.title}}</a>
                            </li>
                        </ul>
                    </div>
                </section>
            </div>
        </div>
    </main>
    <!-- 底部内容 -->
    <footer class="footer">
        <div class="footer-inner">
            <a title="主页" href="#">帮助中心</a>
            <!-- 语言内容 -->
            <div class="footer-language-selector">
                <div class="dropdown language-selector" aria-haspopup="true">
                    <div class="row clearfix">
                        <div class="col-md-12 column">
                            <div class="btn-group dropup">
                                <a class="yuyan" data-toggle="dropdown" style="color:#4f6d8c ;border: none">简体中文<img
                                        src="public/images/xiangxia.svg" /></button>
                                    <ul class="dropdown-menu" style="margin-left: -50px;">
                                        <li>
                                            <a href="#"> Deutsch</a>
                                        </li>
                                        <li>
                                            <a href="#"> English (US)</a>
                                        </li>
                                        <li>
                                            <a href="#">Español</a>
                                        </li>
                                        <li>
                                            <a href="#"> Français</a>
                                        </li>
                                        <li>
                                            <a href="#">日本語</a>
                                        </li>
                                        <li>
                                            <a href="#">한국어</a>
                                        </li>
                                        <li>
                                            <a href="#">Português</a>
                                        </li>
                                        <li>
                                            <a href="#"> Русский</a>
                                        </li>
                                        <li>
                                            <a href="#"> Türkçe</a>
                                        </li>
                                        <li>
                                            <a href="#">Tiếng Việt</a>
                                        </li>
                                        <li>
                                            <a href="#">繁體中文</a>
                                        </li>
                                    </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </footer>
</body>
<iframe src="login.html" id="login" style="display:none;width: 100%;height: 100%;position: absolute;top: 0px;"
    frameborder="no" scrolling="no"></iframe>
<!-- js代码 -->
<script type="text/javascript">
    $(function () {
        // 公告的方法
        category();

        att();

        var cname = window.localStorage.getItem("cname");
        $("#cname").html(cname);
    })

    // 公告ajax
    function category() {
        //传id
        var id = window.localStorage.getItem("Categoryid");
        $.ajax({
            url: "http://192.168.137.1:5001/api/values/ArticleList?id=" + id,
            type: "post",
            dataType: "json",
            success: function (result) {
                new Vue({
                    el: "#category",
                    data: {
                        datas: result
                    }
                })
            },
            error: function () {
                //   alert("网络数据错误！");

            }
        })
    }

    //关注
    $("#attend").click(function () {
        var id = window.localStorage.getItem("Categoryid");
        var token = getToken();
        headerSetup(token);
        $.ajax({
            url: "http://192.168.137.1:5001/api/values/CheckAttent",
            type: "get",
            dataType: "Json",
            data: {
                "CategoryId": id,
                "token": token,
            },
            success: function (result) {
                var isattent = "1"; //关注(全局)
                if (result) { //true
                    isattent = "0";
                } else {
                    isattent = "1";
                }
                var datas = {
                    id: id,
                    token: token,
                    isAttent: isattent
                }
                Attentss(datas);
            },
            error: function () {
                $("#login").css("display", "block"); //没有登录先登陆才能关注

            }
        })


    })
     //关注状态
    function Attentss(data) {
        $.ajax({
            url: "http://192.168.137.1:5001/api/values/Attent",
            type: "get",
            dataType: "json",
            data: data,
            success: function (results) {
                window.location.reload();//页面刷新
            },
            error: function () {
                //   alert("网络数据错误！");
            }
        })
    }


    function att() {
        var id = window.localStorage.getItem("Categoryid");
        var token = getToken();
        headerSetup(token);
        $.ajax({
            url: "http://192.168.137.1:5001/api/values/CheckAttent",
            type: "get",
            dataType: "json",

            data: {
                "CategoryId": id,
                "token": token,
            },
            success: function (result) {
                if (result) {
                    $("#attend").text("正在关注");
                } else {
                    $("#attend").text("关注");
                }
                //  $("#iframe").css("display","none")
            },
            error: function () {

            }
        })


    }
</script>

</html>